// MESSAGE ADRC_TUNING support class

#pragma once

namespace mavlink {
namespace fppa {
namespace msg {

/**
 * @brief ADRC_TUNING message
 *
 * ADRC tuning information.
 */
struct ADRC_TUNING : mavlink::Message {
    static constexpr msgid_t MSG_ID = 251;
    static constexpr size_t LENGTH = 109;
    static constexpr size_t MIN_LENGTH = 109;
    static constexpr uint8_t CRC_EXTRA = 76;
    static constexpr auto NAME = "ADRC_TUNING";


    uint64_t time_boot_ms; /*< [ms] Timestamp (time since system boot). */
    float td_x1; /*< [deg/sec] Transient process for tracked signal. */
    float td_x2; /*< [deg/sec/sec] Differential value of transient process for tracked signal. */
    float td_r; /*<  Velocity factor. */
    float td_h; /*<  Step factor. */
    float td_N0; /*<  Coefficient  of step factor. */
    float td_damp_c; /*<  Damp factor. */
    float td_h0; /*<  The new step factor. */
    float td_fh; /*<  Optimal differential increment of transient process for tracked signal. */
    float eso_z1; /*<  Observed component. */
    float eso_z2; /*<  Observed component. */
    float eso_z3; /*<  Observed component. */
    float eso_e; /*<  Error of state. */
    float eso_y; /*<  System output. */
    float eso_fe; /*<  First-order term estimator. */
    float eso_fe1; /*<  Second-order term estimator. */
    float eso_beta_01; /*<  First-order term factor. */
    float eso_beta_02; /*<  Second-order term factor. */
    float nlsef_beta0; /*<  Integral factor. */
    float nlsef_beta1; /*<  Proportion factor. */
    float nlsef_beta2; /*<  Differential factor. */
    float nlsef_alpha1; /*<  Curvature factor. */
    float nlsef_alpha2; /*<  Curvature factor. */
    float nlsef_a; /*<  Reserved. */
    float nlsef_b; /*<  Reserved. */
    float nlsef_c; /*<  Reserved. */
    uint8_t axis; /*<  Axis of antenna. */


    inline std::string get_name(void) const override
    {
            return NAME;
    }

    inline Info get_message_info(void) const override
    {
            return { MSG_ID, LENGTH, MIN_LENGTH, CRC_EXTRA };
    }

    inline std::string to_yaml(void) const override
    {
        std::stringstream ss;

        ss << NAME << ":" << std::endl;
        ss << "  time_boot_ms: " << time_boot_ms << std::endl;
        ss << "  td_x1: " << td_x1 << std::endl;
        ss << "  td_x2: " << td_x2 << std::endl;
        ss << "  td_r: " << td_r << std::endl;
        ss << "  td_h: " << td_h << std::endl;
        ss << "  td_N0: " << td_N0 << std::endl;
        ss << "  td_damp_c: " << td_damp_c << std::endl;
        ss << "  td_h0: " << td_h0 << std::endl;
        ss << "  td_fh: " << td_fh << std::endl;
        ss << "  eso_z1: " << eso_z1 << std::endl;
        ss << "  eso_z2: " << eso_z2 << std::endl;
        ss << "  eso_z3: " << eso_z3 << std::endl;
        ss << "  eso_e: " << eso_e << std::endl;
        ss << "  eso_y: " << eso_y << std::endl;
        ss << "  eso_fe: " << eso_fe << std::endl;
        ss << "  eso_fe1: " << eso_fe1 << std::endl;
        ss << "  eso_beta_01: " << eso_beta_01 << std::endl;
        ss << "  eso_beta_02: " << eso_beta_02 << std::endl;
        ss << "  nlsef_beta0: " << nlsef_beta0 << std::endl;
        ss << "  nlsef_beta1: " << nlsef_beta1 << std::endl;
        ss << "  nlsef_beta2: " << nlsef_beta2 << std::endl;
        ss << "  nlsef_alpha1: " << nlsef_alpha1 << std::endl;
        ss << "  nlsef_alpha2: " << nlsef_alpha2 << std::endl;
        ss << "  nlsef_a: " << nlsef_a << std::endl;
        ss << "  nlsef_b: " << nlsef_b << std::endl;
        ss << "  nlsef_c: " << nlsef_c << std::endl;
        ss << "  axis: " << +axis << std::endl;

        return ss.str();
    }

    inline void serialize(mavlink::MsgMap &map) const override
    {
        map.reset(MSG_ID, LENGTH);

        map << time_boot_ms;                  // offset: 0
        map << td_x1;                         // offset: 8
        map << td_x2;                         // offset: 12
        map << td_r;                          // offset: 16
        map << td_h;                          // offset: 20
        map << td_N0;                         // offset: 24
        map << td_damp_c;                     // offset: 28
        map << td_h0;                         // offset: 32
        map << td_fh;                         // offset: 36
        map << eso_z1;                        // offset: 40
        map << eso_z2;                        // offset: 44
        map << eso_z3;                        // offset: 48
        map << eso_e;                         // offset: 52
        map << eso_y;                         // offset: 56
        map << eso_fe;                        // offset: 60
        map << eso_fe1;                       // offset: 64
        map << eso_beta_01;                   // offset: 68
        map << eso_beta_02;                   // offset: 72
        map << nlsef_beta0;                   // offset: 76
        map << nlsef_beta1;                   // offset: 80
        map << nlsef_beta2;                   // offset: 84
        map << nlsef_alpha1;                  // offset: 88
        map << nlsef_alpha2;                  // offset: 92
        map << nlsef_a;                       // offset: 96
        map << nlsef_b;                       // offset: 100
        map << nlsef_c;                       // offset: 104
        map << axis;                          // offset: 108
    }

    inline void deserialize(mavlink::MsgMap &map) override
    {
        map >> time_boot_ms;                  // offset: 0
        map >> td_x1;                         // offset: 8
        map >> td_x2;                         // offset: 12
        map >> td_r;                          // offset: 16
        map >> td_h;                          // offset: 20
        map >> td_N0;                         // offset: 24
        map >> td_damp_c;                     // offset: 28
        map >> td_h0;                         // offset: 32
        map >> td_fh;                         // offset: 36
        map >> eso_z1;                        // offset: 40
        map >> eso_z2;                        // offset: 44
        map >> eso_z3;                        // offset: 48
        map >> eso_e;                         // offset: 52
        map >> eso_y;                         // offset: 56
        map >> eso_fe;                        // offset: 60
        map >> eso_fe1;                       // offset: 64
        map >> eso_beta_01;                   // offset: 68
        map >> eso_beta_02;                   // offset: 72
        map >> nlsef_beta0;                   // offset: 76
        map >> nlsef_beta1;                   // offset: 80
        map >> nlsef_beta2;                   // offset: 84
        map >> nlsef_alpha1;                  // offset: 88
        map >> nlsef_alpha2;                  // offset: 92
        map >> nlsef_a;                       // offset: 96
        map >> nlsef_b;                       // offset: 100
        map >> nlsef_c;                       // offset: 104
        map >> axis;                          // offset: 108
    }
};

} // namespace msg
} // namespace fppa
} // namespace mavlink
